<template>
	<view class="auth flex_c">

		<!-- <view class="nav_bar" style="background-color: rgba(255, 255, 255, 1);">
			<uni-nav-bar color="#333" left-icon="left" title="实人认证" :border='false' :fixed="true"
				background-color="transparent" @clickLeft="$native.getAuth()"></uni-nav-bar>
		</view>
		
		<view class="nav_box"></view> -->
		<!-- :type=="code == 0 ? '' : ''" -->
		<view class="box flex_c">
			<view class="icon">
				<uni-icons :size="60" :color="code == 0 ? '#2DD9A5' : '#FDCA5D'"
					:type="code == 0 ? 'checkbox-filled' : 'info-filled'"></uni-icons>
			</view>


			<view class="title">{{ getText() }}</view>
		</view>
		<view>

		</view>

		<view class="btn" @click="getAuth">返回</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				code: -1,

				user_id: 0,
				
				from_type: 0,
			}
		},
		methods: {
			getText() {
				if (this.code == 0) {
					return '实人认证成功';
				}
				if (this.code == -5023) {
					return '光线太强，请到室内识别';
				}
				if (this.code == -5018) {
					return '未识别到指定动作';
				}
				if (this.code == -5008) {
					return '声音未能识别，请大声慢读一遍数字';
				}
				if (this.code == 66660010) {
					return '姓名和身份证不一致，请确认';
				}
				if (this.code == 66660004) {
					return '无法确认为同一人';
				}
				if (this.code == 66660016) {
					return '视频或图片异常';
				}
				if (this.code == 66660015) {
					return '姓名或身份证号格式不正确';
				}
				if (this.code == 66660011) {
					return '未完成认证或认证结果已过期';
				}
				if (this.code == 66660005) {
					return '此证件信息不支持校验';
				}
				if (this.code == 66660003) {
					return '试用版最大刷脸次数已超';
				}
				if (this.code == 66660002) {
					return '服务不可用（已欠费或主动停服，请联系技术支持确认）';
				}
				if (this.code == 66660000) {
					return '请求参数异常';
				}
				if (this.code == 999999) {
					return '网络不给力，请稍后重试';
				}
				if (this.code == 66660035) {
					return '未识别到人脸，请确保正脸对框且清晰完整';
				}
				if (this.code == 66660023) {
					return '请确保本人操作且正脸对框';
				}
				if (this.code == 66660018) {
					return '操作超时，请退出重试';
				}
				if (this.code == 66660017) {
					return '验证次数超限';
				}
				if (this.code == 400601) {
					return '视频或图片异常';
				}
				if (this.code == 400600) {
					return '【微信】下载视频失败，请重试';
				}
				if (this.code == 400506) {
					return '请求频率过高，请稍后再试';
				}
				if (this.code == 400106) {
					return '不合法请求';
				}
				if (this.code == 400103) {
					return 'IP 未加入白名单列表（请线下联系技术支持进行配置）';
				}
				if (this.code == 400101) {
					return '签名校验不通过';
				}
				if (this.code == 66665001) {
					return '请确保本人操作且正脸对框';
				}
				if (this.code == 66662001) {
					return '无此授权结果';
				}
				if (this.code == 66660046) {
					return '比对源照片无法处理';
				}
				if (this.code == 66660044) {
					return '应用服务版本过低，请升级';
				}
				if (this.code == 66660041) {
					return '脸部有遮挡或闭眼，请重试';
				}
				if (this.code == 66660037) {
					return '照片出现多张脸';
				}
			},

			sendStatus() {
				this.$get('/user/setAuthStatus',{
					user_id: this.user_id,
					auth_type: this.auth_type,
				});
			},

			getAuth() {
				if(this.from_type == 1){
					window.history.back();
				}else {
					if (uni.getSystemInfoSync().platform == 'android') {
						AndroidFunction.getAuth();
					} else {
						if (window.webkit) {
							// 调原生回退
							window.webkit.messageHandlers.getAuth.postMessage('');
						}
					}
				}
				
			}
		},

		onLoad(option) {
			this.code = option.code;
			this.user_id = option.user_id;
			this.auth_type = option.auth_type;
			this.from_type = option.type;
			if (this.code == 0) {
				this.sendStatus();
			}
		}
	}
</script>

<style lang="less" scoped>
	.auth {
		padding: 10vh 0 8vh;
		min-height: 100vh;
		background: #FFF;
	}

	.box {
		flex: 1;
	}

	.title {
		font-weight: 600;
		font-size: 40rpx;
		color: #131313;
		margin-top: 20rpx;
	}

	.text {}

	.btn {
		width: 686rpx;
		height: 100rpx;
		background: #FD2A53;
		border-radius: 50rpx;
		font-weight: 500;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 100rpx;
		text-align: center;
	}
</style>